<?php

namespace App\Http\Controllers;

use App\Http\Requests\MemberRequest as Request;
use App\Models\Member as Model;
use App\Models\Member;
use App\Notifications\SysNotify;
use Iamxcd\LaravelCRUD\Traits\HasCrud;
use Iamxcd\LaravelCRUD\Traits\HasOption;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Notification;

class MemberController extends Controller
{
    use HasCrud, HasOption;

    protected $app;

    public function __construct(Model $model)
    {
        $this->model = $model;
        $this->request = app(Request::class);
        $this->optionLabel = 'nick_name';
    }

    public function updateProfile(Request $request)
    {
        $data = $request->validated();
        $this->model::query()->where('id', Auth::id())->update($data);
        return $this->responseMessage('修改成功');
    }

    public function me()
    {
        $data =  Member::query()
            ->find(Auth::id());
        return $this->response($data);
    }
}
